package com.haiyou.dc.thread;

public class StopThread implements Runnable {

    private Boolean flag = true;

    @Override
    public void run() {
        int i = 0;
        while (flag) {
            System.out.println("------>" + i++);
        }
    }

    private void stop() {
        this.flag = false;
    }

    public static void main(String[] args) {
        StopThread stopThread = new StopThread();
        new Thread(stopThread).start();

        for (int i = 0; i < 100; i++) {
            if (i == 88) {
                stopThread.stop();
            }
            System.out.println("------------------->" + i);
        }
    }
}
